Add avoid_direct_collection_equality_checks lint - #546
Merged
cupofme merged 10 commits intoAug 5, 2026
Conversation
…quality_checks.dart Co-authored-by: Piotr Rogulski <piotr.rogulski@leancode.pl>
PiotrRogulski
approved these changes
Aug 5, 2026
| @override | ||
| List<String>? get fixArguments { | ||
| final binary = _targetBinary(node); | ||
| final kind = binary == null |
Member
There was a problem hiding this comment.
I'd do binary! as well in these fixArguments getters
cupofme
deleted the
feature/avoid_direct_collection_equality_checks-lint
branch
August 5, 2026 12:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comparing collections with ==/!= in Dart checks identity, not contents — so [1, 2] == [1, 2] is false. It's an easy mistake to make and a painful one to debug, since the code reads like it should work.
This adds a lint that flags direct ==/!= comparisons between List, Set, or Map values (and their subtypes) when both sides are the same kind of collection.
Each warning comes with two quick fixes:
listEquals(a, b)/setEquals/mapEqualsfrom package:flutter/foundation.dartListEquality<int>().equals(a, b)/SetEquality/MapEqualityfrom package:collectionThe messages and fix names adapt to the collection type (e.g. it suggests listEquals for a list, mapEquals for a map), and the package:collection fix fills in the type argument so you don't get an inference warning afterwards.
Screen.Recording.2026-07-15.at.16.30.20.mov